﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class picnews : System.Web.UI.Page
{
	public string SqlClass = "";
    protected void Page_Load(object sender, EventArgs e)
    {
		if (Session["User"]==null)
		{
			Response.Write("<script language=javascript>alert('您没有管理权限或者还没有登录，请先登录！');window.open('../login.aspx','_top');</script>");
			Response.End();
		}
		
		if (!Page.IsPostBack)
        {
            ShowData();
        }
		

    }
    private void ShowData()
    {
		SqlClass = "and picurl<>'' and hotpicnews=1";
        AspNetPager1.RecordCount = (int)Socut.Data.ExecuteScalar("select count(*) from web_music where picurl<>'' and hotpicnews=1");
        string ExecSQL="select web_music.id,web_music.AddTime,web_music.Title,web_music_smallclass.smallclassname from web_music,web_music_smallclass where web_music.smallclassid=web_music_smallclass.id " + SqlClass + " order by web_music.id desc";
        DataSet ds = new DataSet();
        ds=Socut.Data.ExecuteDataSet(ExecSQL, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        ShowData();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["Ccheck"];
        if (string.IsNullOrEmpty(ids))
        {
            CommonFunction.ShowMessage("请选择要删除的项");
        }
        else
        {
            Socut.Data.ExecuteNonQuery("DELETE from web_music where id in (" + ids + ")");
            CommonFunction.ShowMessage("删除成功","default.aspx");
        }
    }


    private bool check_class(string[] ksarry, string ksid)
    {
        for (int i = 0; i < ksarry.Length; i++)
        {
            if (ksarry[i] == ksid)
            {
                return true;
            }
        }
        return false;
    }

}
